package WrittenTest;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.*;
import java.io.*;

class Read2 { // 自定义快速读入
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

public class test32 {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));
    public static Read2 in = new Read2();

    public static void main(String[] args) throws IOException {
        int n = in.nextInt(), q = in.nextInt();
        List<Long> list = new ArrayList<>();
        long[] nums = new long[n];
        long sum = 0;
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextLong();
            if (nums[i] == 0) {
                tmp++;
            }
            sum += nums[i];
        }
        for (int i = 0; i < q; i++) {
            long a = in.nextLong(), b = in.nextLong();
            long max = Math.max(a, b), min = Math.min(a, b);
            long tmp1 = sum + min * tmp, tmp2 = sum + max * tmp;
            list.add(tmp1);
            list.add(tmp2);
            tmp1 = tmp2 = sum;
        }
        int count = 1;
        for (Long x : list) {
            out.print(x + " ");
            if (count % 2 == 0) {
                out.println();
            }
            count++;
        }
        out.close();
    }
}